package com.twt.common.utils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @Desciption:
 * @ClassName:SpringContextUtil
 * @Author:TwT
 * @Date:2022/6/3 10:21
 * @Version:1.0
 **/
@Component
public class SpringContextUtil implements ApplicationContextAware {

    private static ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        SpringContextUtil.applicationContext = applicationContext;
    }

    /**
     * 获取spring命名空间
     * @return
     */
    public static ApplicationContext getSpringContext(){
        return SpringContextUtil.applicationContext;
    }
}